/**
 * 
 */
package org.jenkon.commons.collection.iterator;

import java.util.Iterator;
import java.util.List;

/**
 * @author Jens Konopka
 * 
 */
public class ReverseArrayIterator<E> implements Iterator<E> {

	private int current;
	private final E[] values;

	/**
	 * @param values {@link List} with the values
	 */
	public ReverseArrayIterator(final E[] values) {
		this.values = values;
		this.current = values.length - 1;
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see java.util.Iterator#hasNext()
	 */
	@Override
	public boolean hasNext() {
		return current > -1;
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see java.util.Iterator#next()
	 */
	@Override
	public E next() {
		return values[current--];
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see java.util.Iterator#remove()
	 */
	@Override
	public void remove() {
		throw new UnsupportedOperationException("remove is not supported");
	}

}
